﻿/// <reference path="jquery-1.4.2.min.js" />

var swfVersionStr = "9.0.0";
var xiSwfUrlStr = "/!js/swfobject/playerProductInstall.swf";
var flashvars = {};
var params = {};
params.quality = "high";
params.bgcolor = "#000000";
params.allowscriptaccess = "sameDomain";
params.allowfullscreen = "true";
params.wmode = ""; //transparent
var attributes = {};
attributes.id = "previewPlayer";
attributes.name = "previewPlayer";
attributes.align = "middle";

$(function () {
    //收藏
    $('.favorite').click(function (e) {
        if ('<%=pagebase.VerifiedUserID %>' != '') {
            var node = this;
            var command = $(node).find('input').attr('name');
            var id = $(this).find('input').val();
            $.ajax({
                url: '/Handler/ServiceHandler.ashx',
                type: 'post',
                data: { ServiceID: id, UserID: '<%=pagebase.VerifiedUserID %>', Command: command },
                success: function (response) {
                    $(node).find('input').attr('name', command == 'Save' ? 'UnSave' : 'Save')
                    $(node).find('span').text(command == 'Save' ? '取消收藏' : '收藏').attr('class', command == 'Save' ? 'car unsubscribe' : 'share collectionbg');
                    $("#lblFavCount").text(response);
                }
            });
        }
        else {
            alert('请先登录!');
        }
        preventDefault(e);
    });

    //附件

    var imgHtml = "";     //分组图HTML
    var imgIndex = 0;  //被点击图片索引

    $('.thumbnail').each(function () {
        var imgpath = $(this).find('#imgPath').val();
        var videopath = $(this).find('#videoPath').val();
        var serviceid = $(this).find('#hfserviceid').val();
        var $showDiv = $('#show_' + serviceid);

        var pointstr = imgpath.split('.');
        if (pointstr.length > 0) {
            bigImgPath = pointstr[0] + '_preview.jpg';
            $showDiv.append($('<a>').addClass('group ' + serviceid).attr('href', bigImgPath).click(function () {
                $(this).colorbox({ rel: serviceid });
            }));
        }

        $(this).click(function () {
            var showvideo = $showDiv.find("#videoContent");
            if (videopath == "") {
                pointstr = imgpath.split('.');
                if (pointstr.length > 0) {
                    var bigImgPath = pointstr[0] + '_preview.jpg';
                    $showDiv.find('img').remove();
                    $showDiv.find("a[href='" + bigImgPath + "']").html("<img src='" + imgpath + "' alt='' />");
                    showvideo.hide();
                }
            }
            else {
                var playHtml = "<embed src=\"/!swf/VideoPlayer/VPlayer.swf?t=d&s=&v=" + videopath + "&h=0&lo=0\" quality=\"high\" width=\"350\" height=\"350\" align=\"middle\" allowscriptaccess=\"always\" allowfullscreen=\"true\" wmode=\"transparent\" type=\"application/x-shockwave-flash\"></embed>";
                showvideo.html(playHtml);
                showvideo.show();
            }
        });
    });

    $('.videopic_list').each(function () {
        $(this).find(".thumbnail").eq(0).click();
    });

    //登录验证
    //login(width,height,href)修改参数可控制弹出层的大小及打开的页面，参数可以为空
    if ('<%=pagebase.IsVerified %>' == 'False') {
        $('#imgBtnOrder').click(function (e) {
            login();
            preventDefault(e);
        });
        $('#orderWithExtra').click(function () {
            login();
            preventDefault(e);
        });
    }


    $("[id$=imgBtnEdit]").mouseover(function () {
        $(this).attr("src", "/!images/edit_on.png");
    }).mouseout(function () {
        $(this).attr("src", "/!images/edit_off.png");
    });
});


function setPlayVideo(str) {
    alert(111);
}  